package com.network;

import ch.qos.logback.core.net.server.Client;

import java.io.DataOutputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

public class TcpClient {
    public static void main(String[] args) throws Exception{
        Scanner scanner = new Scanner(System.in);
        Socket socket = new Socket(InetAddress.getLocalHost(), 6666);
        ClientReceive clientReceive = new ClientReceive(socket);
        clientReceive.start();
        OutputStream outputStream = socket.getOutputStream();
        DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
        while(true){
            System.out.println("请输入发送的信息");
            String temp = scanner.nextLine();
            if(temp.equals("exit")){
                socket.close();
                scanner.close();
                outputStream.close();
                break;
            }
            dataOutputStream.writeUTF(temp);
            dataOutputStream.flush();
        }

    }
}
